<template>
	<view class="box">
		<!-- Top Section -->
		<view class="box_top">
			<view class="top-left">
				<text style="color: #4170FF;">相关问题</text>
				<text style="margin-left: 15rpx;">金蝶写在软件提示还有金蝶文件...</text>
			</view>
			<view class="top-right">
				>
			</view>
		</view>

		<!-- Form Section -->
		<view class="box_lei">
			<!-- Project Selection -->
			<view class="box_kapian">
				<view class="kapian_xiangmu">
					<view>所属项目</view>
					<view style="color: #999999;">请选择 ></view>
				</view>
				<view class="kapian_bT">
					<view class="biaotinie">
						<input v-model="data.title" type="text" class="title-input" placeholder="请填写标题" />
					</view>
					<view class="yuan">×</view>
				</view>
			</view>

			<!-- Date Section -->
			<view class="box_bjq">
				<view class="bjq_rq">
					<view class="yuanq"></view>
					<view class="shu"></view>
					<view class="yuanq"></view>
				</view>
				<view class="date_riqi">
					<view class="time-item">
						<view>开始时间：</view>
						<view>2024-03-11 08:00 周一</view>
					</view>
					<view class="time-item">
						<view>结束时间：</view>
						<view>2024-03-11 22:00 周一</view>
					</view>
				</view>
			</view>

			<!-- Additional Fields -->
			<view class="box_grade">
				<view class="Important_level">
					<view>重要等级</view>
					<view style="color: #999999;">请选择 ></view>
				</view>
				<view class="Reminder_Time">
					<view>提醒时间</view>
					<view style="color: #999999;">请选择 ></view>
				</view>
				<view class="Planned_working_hours">
					<view>计划工时</view>
					<view style="color: #999999; display: flex;align-items: center;">
						<input v-model="data.workingHours" class="kuang" type="number" placeholder="输入天数" />天
					</view>
				</view>
				<view class="person_in_charge">
					<view>负责人</view>
					<view style="color: #999999;">请选择 ></view>
				</view>
			</view>
		</view>

		<!-- Action Buttons -->
		<view class="box_button">
			<view class="save" @click="onsave">保存</view>
			<view class="submit" @click="onsubmit">提交</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: {
					project: "", // 所属项目
					title: "", // 标题
					startTime1: "2024-03-11 08:00", // 开始时间1
					startTime2: "2024-03-11 22:00", // 开始时间2
					workingHours: "", // 计划工时
				}
			};
		},
		methods: {
			onsave() {
				// Save data to local storage
				uni.setStorageSync('savedData', this.data);
				console.log('数据已保存，当前保存的数据为：', this.data);
				uni.showToast({
					title: '保存成功',
					icon: 'success'
				});
			},
			onsubmit() {
				// Validation before submit
				if (!this.data.project) {
					uni.showToast({
						title: '请选择所属项目',
						icon: 'none'
					});
					return;
				}
				if (!this.data.title) {
					uni.showToast({
						title: '请填写标题',
						icon: 'none'
					});
					return;
				}
				if (!this.data.workingHours) {
					uni.showToast({
						title: '请输入计划工时',
						icon: 'none'
					});
					return;
				}

				// Submit data to the server
				uni.request({
					url: 'your_server_url_here',
					method: 'POST',
					data: this.data,
					success: (res) => {
						if (res.statusCode === 200) {
							uni.showToast({
								title: '提交成功',
								icon: 'success'
							});
						} else {
							uni.showToast({
								title: '提交失败，请稍后再试',
								icon: 'none'
							});
						}
					},
					fail: (err) => {
						uni.showToast({
							title: '网络错误，请检查网络连接',
							icon: 'none'
						});
					}
				});
			}
		}
	};
</script>


<style lang="less">
	@import url("./ReqBuilder.css");
</style>